import time

import pyperclip
from pathlib import Path

clip_file = Path(__file__).parent / 'clip.txt'


if __name__ == '__main__':
    while True:
        time.sleep(0.3)
        clip_content = pyperclip.paste()
        if isinstance(clip_content, str) and clip_content.startswith('https://pbs.twimg.com'):
            with open(clip_file, 'a') as f:
                f.write(clip_content)
                f.write('\n')
                print(clip_content)
                pyperclip.copy('')
